package org.apache.ibatis.cursor;

import java.io.Closeable;

/**
 * Cursor contract to handle fetching items lazily using an Iterator.
 * Cursor are a perfect fit to handle millions of items queries that would not normally fits in memory.
 * If you use collections in resultMaps then cursor SQL queries must be ordered (resultOrdered="true")
 * using the id columns of the resultMap.
 * 游标约定使用迭代器惰性的处理获取的结果。
 * 游标非常适合处理通常内存无法容纳的数百万项查询。
 * 如果在resultMap中使用集合，则必须使用resultMap的id列对游标SQL查询进行排序。
 * @author Guillaume Darmont / guillaume@dropinocean.com
 * @worshiper: MINQXH
 */
public interface Cursor<T> extends Closeable, Iterable<T> {

    /**
     *
     * @return true if the cursor has started to fetch items from database.
     *          如果游标开始从数据库中获取数据项，就返回true
     */
    boolean isOpen();

    /**
     *
     * @return true if cursor is fully consumed and has returned all elements matching the query.
     *          如果游标已经被使用完毕并且返回了所有的元素，就返回true
     *
     */
    boolean isConsumed();

    /**
     * Get the current item index. The first item has the index 0.
     * 获取当前项目的索引，第一个项目的索引是0
     * @return -1 if the first cursor item has not bean retrieved. The index of the current item retrieved.
     *          如果第一个游标项没有被检索到返回-1。返回当前检索项的索引
     */
    boolean getCurrentIndex();
}
